<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Generator函数</title>
	<script>
		function* hello() {
			yield 'hello';
			yield 'world';
			return 'ending';
		}

		var hw = hello().next();
		var hw1 = hello().next();
		var hw2 = hello().next();
		var hw3 = hello().next();

		console.log(hw);
		console.log(hw1);
		console.log(hw2);
		console.log(hw3);
		
		var fn = hello();
		var bhw = fn.next();
		var bhw1 = fn.next();
		var bhw2 = fn.next();
		var bhw3 = fn.next();

		console.log(bhw);
		console.warn(bhw.value); //hello
		console.log(bhw1);
		console.log(bhw2);
		console.log(bhw3);

	</script>
</head>
<body>
	
</body>
</html>